﻿using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using Rhino.Mocks;
using JSMVP;
using JSMVP.Presenters;
using JSMVP.Domain;
namespace JSMVP.Tests
{
    [TestFixture]
    public class ShoppingCartTester
    {
        [TestFixture]
        public class When_ShoppingCart_Is_Displayed
        {
            MockRepository mocks;
            ICartView view;
            Cart cart;
            ShoppingCartPresenter presenter;
            [SetUp]
            public void Setup()
            {
                mocks = new MockRepository();
                view = mocks.CreateMock<ICartView>();
                cart = new Cart();
                presenter = new ShoppingCartPresenter(view, cart);
            }
            [TearDown]
            public void TearDown()
            {
                mocks = null;
                view = null;
                cart = null;
                presenter = null;
            }
            [Test]
            public void Should_Display_Empty_Cart_Message_When_No_Products_Have_Been_Added_To_Cart()
            {
                view.ErrorMessage = "There are No Items In Your Cart";
                LastCall.On(view).IgnoreArguments();
                mocks.ReplayAll();
                presenter.DisplayCart();
                mocks.VerifyAll();
            }

            [Test]
            public void Should_Diplay_Product_Items()
            {
                Product prod1 = new Product();
                CartItem item1 = new CartItem();
                item1.product = prod1;
                item1.quantity = 1;
                cart.Items.Add(item1);
                view.CartItems = 
                mocks.ReplayAll();
                presenter.DisplayCart();
                mocks.VerifyAll();
            }

            public void Should_Display_SubTotal()
            {
                Product prod1 = new Product();
                CartItem item1 = new CartItem();
                item1.product = prod1;
                item1.quantity = 1;
                cart.Items.Add(item1);
                view.SubTotal = cart.SubTotal;
                mocks.ReplayAll();
                presenter.DisplayCart();
                mocks.VerifyAll();

            }

        }
    }
}
    